package cn.com.tianpeidong.restaurantadmin.common.constant;

import java.util.UUID;

/**
 * @author tianpeidong
 */
public class ErrorResponse {

    public final String id;
    public final Integer status;
    public String msg;

    public ErrorResponse(Integer status, String msg) {
        this.id= UUID.randomUUID().toString();
        this.status = status;
        this.msg = msg;
    }

    public static Builder code(PlatformError error) {
        return new Builder(error);
    }

    public static class Builder {
        private final PlatformError platformError;

        public Builder(PlatformError error) {
            this.platformError = error;
        }

        public ErrorResponse build() {
            return new ErrorResponse(platformError.getCode(), platformError.getDescription());
        }

        public ErrorResponse buildWithCustomMsg(String description) {
            return new ErrorResponse(platformError.getCode(), description);
        }

    }

}